<!--
 * @Author: your name
 * @Date: 2020-08-02 14:09:07
 * @LastEditTime: 2020-10-18 13:14:35
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \project\羊绒产业园\源码\src\views\sendList.vue
-->
<template>
  <div class="send-list">
    <heads :title="$route.query.type === '2' ? '我卖出去的' : $route.query.type === '3' ? '我买到的' : '我收藏的'"></heads>
      
   <div class="main-content">
      <van-pull-refresh v-model="isLoading" @refresh="getData" style="min-height: 92vh;">
        <template v-if="list && list.length>0">
          <Cell
            :ListData="item"
            v-for=" (item,index) in list"
            :key="index"
            :Type="labelIndex+1"
            :ShowPrice="true"
            @click.native="jump(item)"
          ></Cell>
        </template>
       <van-empty v-if="!isLoading && list.length <= 0" description="没有更多数据了~" />
            <!-- <van-loading size="24px" v-if="isLoading">加载中...</van-loading> -->
      </van-pull-refresh>
    </div>

    
  
  </div>
</template>

<script>
import { Toast, Popup, Picker, Search, Loading, Dialog,Empty  } from "vant";
import * as Config from "@/js/common/config";
import { mapState } from "vuex";

export default {
  components: {
    heads: resolve => require(["@/components/common/heads"], resolve),
    foots: resolve => require(["@/components/common/foots"], resolve),
    Cell: resolve => require(["@/components/common/cell"], resolve)
  },
  data() {
    return {
      isLoading: true,
      list: [],
       labelList:Config.getSendType()
    };
  },
  watch: {
   '$route.query.type':{
      handler(newVal,oldVal){
        if(newVal !== '4'){
          this.getData();
          return
        }
        this.getCollectData()
       
         
      },
      immediate:true

    },
  },
   computed: {
    ...mapState(["userInfo"])
  },
  methods: {
   // 我发布的  我卖出的 我买到的
    getData() {
      let _this = this;
       _this.isLoading = true;
     if(_this.$route.query.type !== '4'){
       _this.getListData()
       return
     }
      _this.getCollectData()
    },
    // 我发布的  我卖出的 我买到的
    getListData() {
      let _this = this;
      _this.isLoading = true;
      let _param = {
         "type": Number(_this.$route.query.type),
         "salesType":'',
          userId: _this.userInfo.userId,
          "pageNo": _this.pageNo,
          "pageSize": _this.pageSize,
          
      }
      this.$ajax
        .post(`${this.$baseUrl}/portal/users/getUserIssueList`, _param)
        .then(function(res) {
          _this.isLoading = false;
          if (res.data.code == 200) {
            _this.list = res.data.data.list;
          }
        })
        .catch(function(error) {
           _this.isLoading = false;
          console.log(error);
        });
    },
     // 我收藏的
    getCollectData() {
      let _this = this;
      _this.isLoading = true;
      let _param = {
         userId: _this.userInfo.userId,
          "pageNo": _this.pageNo,
          "pageSize": _this.pageSize,
          
      }
      this.$ajax
        .post(`${this.$baseUrl}/portal/users/getCollectList`, _param)
        .then(function(res) {
          _this.isLoading = false;
          if (res.data.code == 200) {
            _this.list = res.data.data.list;
          }
        })
        .catch(function(error) {
           _this.isLoading = false;
          console.log(error);
        });
    },
   
    jump(data) {
      
      this.$router.push({name: `orderDetail`,params:{id:data.detailId,issueId:data.issueId}});
    }
  },
  created() {
   
  }
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="scss" scoped>
.send-list {
   
  .main-content {
    min-height: 92vh;
    margin-top: 0;
    padding: 0.3rem 0;
    box-sizing: border-box;
  }
  .tabs {
    box-sizing: border-box;
    color: #333333;
    .cell {
    }
  }
}
</style>
